import * as echarts from "echarts";
import elementResizeDetectorMaker from "element-resize-detector";

const useEchart = () => {
    const renderEchart = (chartRef, option) => {
        const chart = echarts.init(chartRef.value)
        chart.setOption(option)
        const erd = elementResizeDetectorMaker()
        erd.listenTo(chartRef.value, ele => {
            chart.resize()
        })
    }

    return {
        renderEchart
    }
}

export default useEchart